﻿using System;
using System.Collections.Generic;

class Salaries
{
    static void Main()
    {
        int size = int.Parse(Console.ReadLine());
        string[] employees = new string[size];

        for (int row = 0; row < size; row++)
        {
            employees[row] = Console.ReadLine();
        }

        bool[] calculated = new bool[size];
        long[] salaries = new long[size];

        // Reading every employee in the list
        long result = 0;

        for (int row = 0; row < size; row++)
        {
            result += CalcSalary(employees, row, calculated, salaries);
        }

        Console.WriteLine(result);
    }

    // DFS
    public static long CalcSalary(string[] employees, int row, bool[] calculated, long[] salaries)
    {
        long result = 0;

        if (!calculated[row])
        {
            for (int col = 0; col < employees[row].Length; col++)
            {
                if (employees[row][col] == 'Y')
                {
                    result += CalcSalary(employees, col, calculated, salaries);
                }
            }

            if (result == 0)
            {
                 //No managers found
                salaries[row] = 1;
            }
            else
            {
                salaries[row] = result;
            }

            calculated[row] = true;
        }

        return salaries[row];
    }
}